{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 特征工程\n",
    "数据集来源于Data Hackathon 3.x，所有的特征处理也只做最基本的参考，可自行尝试更多的特征工程工作，参考github里Feature engineering和Kaggle Titanic的案例。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 加载需要的库:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#载入数据:\n",
    "train = pd.read_csv('Train.csv')\n",
    "test = pd.read_csv('Test.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((87020, 26), (37717, 24))"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.shape, test.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 看看数据的基本情况"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "ID                        object\n",
       "Gender                    object\n",
       "City                      object\n",
       "Monthly_Income             int64\n",
       "DOB                       object\n",
       "Lead_Creation_Date        object\n",
       "Loan_Amount_Applied      float64\n",
       "Loan_Tenure_Applied      float64\n",
       "Existing_EMI             float64\n",
       "Employer_Name             object\n",
       "Salary_Account            object\n",
       "Mobile_Verified           object\n",
       "Var5                       int64\n",
       "Var1                      object\n",
       "Loan_Amount_Submitted    float64\n",
       "Loan_Tenure_Submitted    float64\n",
       "Interest_Rate            float64\n",
       "Processing_Fee           float64\n",
       "EMI_Loan_Submitted       float64\n",
       "Filled_Form               object\n",
       "Device_Type               object\n",
       "Var2                      object\n",
       "Source                    object\n",
       "Var4                       int64\n",
       "LoggedIn                   int64\n",
       "Disbursed                  int64\n",
       "dtype: object"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.dtypes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 拿前5条出来看看"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>Gender</th>\n",
       "      <th>City</th>\n",
       "      <th>Monthly_Income</th>\n",
       "      <th>DOB</th>\n",
       "      <th>Lead_Creation_Date</th>\n",
       "      <th>Loan_Amount_Applied</th>\n",
       "      <th>Loan_Tenure_Applied</th>\n",
       "      <th>Existing_EMI</th>\n",
       "      <th>Employer_Name</th>\n",
       "      <th>...</th>\n",
       "      <th>Interest_Rate</th>\n",
       "      <th>Processing_Fee</th>\n",
       "      <th>EMI_Loan_Submitted</th>\n",
       "      <th>Filled_Form</th>\n",
       "      <th>Device_Type</th>\n",
       "      <th>Var2</th>\n",
       "      <th>Source</th>\n",
       "      <th>Var4</th>\n",
       "      <th>LoggedIn</th>\n",
       "      <th>Disbursed</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>ID000002C20</td>\n",
       "      <td>Female</td>\n",
       "      <td>Delhi</td>\n",
       "      <td>20000</td>\n",
       "      <td>23-May-78</td>\n",
       "      <td>15-May-15</td>\n",
       "      <td>300000.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>CYBOSOL</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>N</td>\n",
       "      <td>Web-browser</td>\n",
       "      <td>G</td>\n",
       "      <td>S122</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>ID000004E40</td>\n",
       "      <td>Male</td>\n",
       "      <td>Mumbai</td>\n",
       "      <td>35000</td>\n",
       "      <td>07-Oct-85</td>\n",
       "      <td>04-May-15</td>\n",
       "      <td>200000.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>TATA CONSULTANCY SERVICES LTD (TCS)</td>\n",
       "      <td>...</td>\n",
       "      <td>13.25</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6762.9</td>\n",
       "      <td>N</td>\n",
       "      <td>Web-browser</td>\n",
       "      <td>G</td>\n",
       "      <td>S122</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ID000007H20</td>\n",
       "      <td>Male</td>\n",
       "      <td>Panchkula</td>\n",
       "      <td>22500</td>\n",
       "      <td>10-Oct-81</td>\n",
       "      <td>19-May-15</td>\n",
       "      <td>600000.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>ALCHEMIST HOSPITALS LTD</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>N</td>\n",
       "      <td>Web-browser</td>\n",
       "      <td>B</td>\n",
       "      <td>S143</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ID000008I30</td>\n",
       "      <td>Male</td>\n",
       "      <td>Saharsa</td>\n",
       "      <td>35000</td>\n",
       "      <td>30-Nov-87</td>\n",
       "      <td>09-May-15</td>\n",
       "      <td>1000000.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>BIHAR GOVERNMENT</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>N</td>\n",
       "      <td>Web-browser</td>\n",
       "      <td>B</td>\n",
       "      <td>S143</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ID000009J40</td>\n",
       "      <td>Male</td>\n",
       "      <td>Bengaluru</td>\n",
       "      <td>100000</td>\n",
       "      <td>17-Feb-84</td>\n",
       "      <td>20-May-15</td>\n",
       "      <td>500000.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>25000.0</td>\n",
       "      <td>GLOBAL EDGE SOFTWARE</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>N</td>\n",
       "      <td>Web-browser</td>\n",
       "      <td>B</td>\n",
       "      <td>S134</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 26 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            ID  Gender       City  Monthly_Income        DOB  \\\n",
       "0  ID000002C20  Female      Delhi           20000  23-May-78   \n",
       "1  ID000004E40    Male     Mumbai           35000  07-Oct-85   \n",
       "2  ID000007H20    Male  Panchkula           22500  10-Oct-81   \n",
       "3  ID000008I30    Male    Saharsa           35000  30-Nov-87   \n",
       "4  ID000009J40    Male  Bengaluru          100000  17-Feb-84   \n",
       "\n",
       "  Lead_Creation_Date  Loan_Amount_Applied  Loan_Tenure_Applied  Existing_EMI  \\\n",
       "0          15-May-15             300000.0                  5.0           0.0   \n",
       "1          04-May-15             200000.0                  2.0           0.0   \n",
       "2          19-May-15             600000.0                  4.0           0.0   \n",
       "3          09-May-15            1000000.0                  5.0           0.0   \n",
       "4          20-May-15             500000.0                  2.0       25000.0   \n",
       "\n",
       "                         Employer_Name    ...    Interest_Rate Processing_Fee  \\\n",
       "0                              CYBOSOL    ...              NaN            NaN   \n",
       "1  TATA CONSULTANCY SERVICES LTD (TCS)    ...            13.25            NaN   \n",
       "2              ALCHEMIST HOSPITALS LTD    ...              NaN            NaN   \n",
       "3                     BIHAR GOVERNMENT    ...              NaN            NaN   \n",
       "4                 GLOBAL EDGE SOFTWARE    ...              NaN            NaN   \n",
       "\n",
       "   EMI_Loan_Submitted Filled_Form  Device_Type  Var2  Source  Var4  LoggedIn  \\\n",
       "0                 NaN           N  Web-browser     G    S122     1         0   \n",
       "1              6762.9           N  Web-browser     G    S122     3         0   \n",
       "2                 NaN           N  Web-browser     B    S143     1         0   \n",
       "3                 NaN           N  Web-browser     B    S143     3         0   \n",
       "4                 NaN           N  Web-browser     B    S134     3         1   \n",
       "\n",
       "  Disbursed  \n",
       "0         0  \n",
       "1         0  \n",
       "2         0  \n",
       "3         0  \n",
       "4         0  \n",
       "\n",
       "[5 rows x 26 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.head(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(124737, 27)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#合成一个总的data\n",
    "train['source']= 'train'\n",
    "test['source'] = 'test'\n",
    "data=pd.concat([train, test],ignore_index=True)\n",
    "data.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 数据应用/建模一个很重要的工作是，你要看看异常点，比如说缺省值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "City                      1401\n",
       "DOB                          0\n",
       "Device_Type                  0\n",
       "Disbursed                37717\n",
       "EMI_Loan_Submitted       84901\n",
       "Employer_Name              113\n",
       "Existing_EMI               111\n",
       "Filled_Form                  0\n",
       "Gender                       0\n",
       "ID                           0\n",
       "Interest_Rate            84901\n",
       "Lead_Creation_Date           0\n",
       "Loan_Amount_Applied        111\n",
       "Loan_Amount_Submitted    49535\n",
       "Loan_Tenure_Applied        111\n",
       "Loan_Tenure_Submitted    49535\n",
       "LoggedIn                 37717\n",
       "Mobile_Verified              0\n",
       "Monthly_Income               0\n",
       "Processing_Fee           85346\n",
       "Salary_Account           16801\n",
       "Source                       0\n",
       "Var1                         0\n",
       "Var2                         0\n",
       "Var4                         0\n",
       "Var5                         0\n",
       "source                       0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.apply(lambda x: sum(x.isnull()))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 要对数据有更深的认识，比如说，咱们看看这些字段，分别有多少种取值(甚至你可以看看分布)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Gender这一列数据的不同取值和出现的次数\n",
      "\n",
      "Male      71398\n",
      "Female    53339\n",
      "Name: Gender, dtype: int64\n",
      "\n",
      "Salary_Account这一列数据的不同取值和出现的次数\n",
      "\n",
      "HDFC Bank                                          25180\n",
      "ICICI Bank                                         19547\n",
      "State Bank of India                                17110\n",
      "Axis Bank                                          12590\n",
      "Citibank                                            3398\n",
      "Kotak Bank                                          2955\n",
      "IDBI Bank                                           2213\n",
      "Punjab National Bank                                1747\n",
      "Bank of India                                       1713\n",
      "Bank of Baroda                                      1675\n",
      "Standard Chartered Bank                             1434\n",
      "Canara Bank                                         1385\n",
      "Union Bank of India                                 1330\n",
      "Yes Bank                                            1120\n",
      "ING Vysya                                            996\n",
      "Corporation bank                                     948\n",
      "Indian Overseas Bank                                 901\n",
      "State Bank of Hyderabad                              854\n",
      "Indian Bank                                          773\n",
      "Oriental Bank of Commerce                            761\n",
      "IndusInd Bank                                        711\n",
      "Andhra Bank                                          706\n",
      "Central Bank of India                                648\n",
      "Syndicate Bank                                       614\n",
      "Bank of Maharasthra                                  576\n",
      "HSBC                                                 474\n",
      "State Bank of Bikaner & Jaipur                       448\n",
      "Karur Vysya Bank                                     435\n",
      "State Bank of Mysore                                 385\n",
      "Federal Bank                                         377\n",
      "Vijaya Bank                                          354\n",
      "Allahabad Bank                                       345\n",
      "UCO Bank                                             344\n",
      "State Bank of Travancore                             333\n",
      "Karnataka Bank                                       279\n",
      "United Bank of India                                 276\n",
      "Dena Bank                                            268\n",
      "Saraswat Bank                                        265\n",
      "State Bank of Patiala                                263\n",
      "South Indian Bank                                    223\n",
      "Deutsche Bank                                        176\n",
      "Abhyuday Co-op Bank Ltd                              161\n",
      "The Ratnakar Bank Ltd                                113\n",
      "Tamil Nadu Mercantile Bank                           103\n",
      "Punjab & Sind bank                                    84\n",
      "J&K Bank                                              78\n",
      "Lakshmi Vilas bank                                    69\n",
      "Dhanalakshmi Bank Ltd                                 66\n",
      "State Bank of Indore                                  32\n",
      "Catholic Syrian Bank                                  27\n",
      "India Bulls                                           21\n",
      "B N P Paribas                                         15\n",
      "Firstrand Bank Limited                                11\n",
      "GIC Housing Finance Ltd                               10\n",
      "Bank of Rajasthan                                      8\n",
      "Kerala Gramin Bank                                     4\n",
      "Industrial And Commercial Bank Of China Limited        3\n",
      "Ahmedabad Mercantile Cooperative Bank                  1\n",
      "Name: Salary_Account, dtype: int64\n",
      "\n",
      "Mobile_Verified这一列数据的不同取值和出现的次数\n",
      "\n",
      "Y    80928\n",
      "N    43809\n",
      "Name: Mobile_Verified, dtype: int64\n",
      "\n",
      "Var1这一列数据的不同取值和出现的次数\n",
      "\n",
      "HBXX    84901\n",
      "HBXC    12952\n",
      "HBXB     6502\n",
      "HAXA     4214\n",
      "HBXA     3042\n",
      "HAXB     2879\n",
      "HBXD     2818\n",
      "HAXC     2171\n",
      "HBXH     1387\n",
      "HCXF      990\n",
      "HAYT      710\n",
      "HAVC      570\n",
      "HAXM      386\n",
      "HCXD      348\n",
      "HCYS      318\n",
      "HVYS      252\n",
      "HAZD      161\n",
      "HCXG      114\n",
      "HAXF       22\n",
      "Name: Var1, dtype: int64\n",
      "\n",
      "Filled_Form这一列数据的不同取值和出现的次数\n",
      "\n",
      "N    96740\n",
      "Y    27997\n",
      "Name: Filled_Form, dtype: int64\n",
      "\n",
      "Device_Type这一列数据的不同取值和出现的次数\n",
      "\n",
      "Web-browser    92105\n",
      "Mobile         32632\n",
      "Name: Device_Type, dtype: int64\n",
      "\n",
      "Var2这一列数据的不同取值和出现的次数\n",
      "\n",
      "B    53481\n",
      "G    47338\n",
      "C    20366\n",
      "E     1855\n",
      "D      918\n",
      "F      770\n",
      "A        9\n",
      "Name: Var2, dtype: int64\n",
      "\n",
      "Source这一列数据的不同取值和出现的次数\n",
      "\n",
      "S122    55249\n",
      "S133    42900\n",
      "S159     7999\n",
      "S143     6140\n",
      "S127     2804\n",
      "S137     2450\n",
      "S134     1900\n",
      "S161     1109\n",
      "S151     1018\n",
      "S157      929\n",
      "S153      705\n",
      "S144      447\n",
      "S156      432\n",
      "S158      294\n",
      "S123      112\n",
      "S141       83\n",
      "S162       60\n",
      "S124       43\n",
      "S150       19\n",
      "S160       11\n",
      "S136        5\n",
      "S138        5\n",
      "S155        5\n",
      "S139        4\n",
      "S129        4\n",
      "S135        2\n",
      "S131        1\n",
      "S130        1\n",
      "S132        1\n",
      "S125        1\n",
      "S140        1\n",
      "S142        1\n",
      "S126        1\n",
      "S154        1\n",
      "Name: Source, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "var = ['Gender','Salary_Account','Mobile_Verified','Var1','Filled_Form','Device_Type','Var2','Source']\n",
    "for v in var:\n",
    "    print '\\n%s这一列数据的不同取值和出现的次数\\n'%v\n",
    "    print data[v].value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 紧接着你就可以开始处理你的字段(特征)了\n",
    "我这里只做了一些简单的处理，你大可在我的基础上做更复杂的特征处理"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### City字段处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "724"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(data['City'].unique())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 好像city的类型好多，粗暴一点，这个字段咱们不要了"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "data.drop('City',axis=1,inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### DOB字段处理\n",
    "DOB是出生的具体日期，咱们要具体日期作用没那么大，年龄段可能对我们有用，所有算一下年龄好了"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    23-May-78\n",
       "1    07-Oct-85\n",
       "2    10-Oct-81\n",
       "3    30-Nov-87\n",
       "4    17-Feb-84\n",
       "Name: DOB, dtype: object"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['DOB'].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    37\n",
       "1    30\n",
       "2    34\n",
       "3    28\n",
       "4    31\n",
       "Name: Age, dtype: int64"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#创建一个年龄的字段Age\n",
    "data['Age'] = data['DOB'].apply(lambda x: 115 - int(x[-2:]))\n",
    "data['Age'].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#把原始的DOB字段去掉:\n",
    "data.drop('DOB',axis=1,inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### EMI_Load_Submitted字段处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x10a00d550>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAEBCAYAAACT92m7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHaBJREFUeJzt3X+U1fV95/HniyGISZDBtMRdDI4GsJjVTIhif9h1oito\nu1XSXSk5G2EiJ3sqstG2mw3Y04xszjbR3a2TNKvZtMRBa0oIW38ksUiMXFNXAphI0EBh3HYQiHJO\nBGbjJqGC7/3jfu74Ze78ujPznXsv83qcw8n387mfz/d+ridz39/P5/35fq8iAjMzs6wJ1R6AmZnV\nHgcHMzMr4+BgZmZlHBzMzKyMg4OZmZVxcDAzszKDBgdJayUdlrSrV/1/kLRH0guSPpepXy2pM722\nIFM/T9IuSfsktWfqJ0lan/pslTQz89qy1H6vpKUj/7hmZjYUQ5k53A8szFZIagF+B7g4Ii4G/luq\nnwssBuYC1wH3SlLqdh+wPCLmAHMklc65HDgSEbOBduDudK5pwKeBy4DLgTZJU4f5Oc3MrAKDBoeI\neAY42qv6FuBzEXEitflJqr8BWB8RJyKiC+gE5ks6B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r2a10laSXM+e+EfgYsDEldHcA/zMljf8C+BFvPbqlv/cY6D3fC9yXVr4mAN+KiIcBJP3n9H4H\ngeyd/wH8Iv03mJjG15f+3jdb/2Vgl6TvR8RNkp6VtIvi8tSnJM0Ftqbx/RT4aEQ8L2kDsItiENve\n+w3s9OY7pM3MrIyXlczMrIyXley0JGkBcBdvLa+I4o6kf3M6vadZXrysZGZmZbysZGZmZRwczMys\njIODmZmVcXAwM7MyDg5mZlbm/wPLSNHVButiugAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x109fe5c50>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "data.boxplot(column=['EMI_Loan_Submitted'],return_type='axes')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>EMI_Loan_Submitted</th>\n",
       "      <th>EMI_Loan_Submitted_Missing</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>6762.90</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6978.92</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>30824.65</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10883.38</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   EMI_Loan_Submitted  EMI_Loan_Submitted_Missing\n",
       "0                 NaN                           1\n",
       "1             6762.90                           0\n",
       "2                 NaN                           1\n",
       "3                 NaN                           1\n",
       "4                 NaN                           1\n",
       "5             6978.92                           0\n",
       "6                 NaN                           1\n",
       "7                 NaN                           1\n",
       "8            30824.65                           0\n",
       "9            10883.38                           0"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#好像缺失值比较多，干脆就开一个新的字段，表明是缺失值还是不是缺失值\n",
    "data['EMI_Loan_Submitted_Missing'] = data['EMI_Loan_Submitted'].apply(lambda x: 1 if pd.isnull(x) else 0)\n",
    "data[['EMI_Loan_Submitted','EMI_Loan_Submitted_Missing']].head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#原始那一列就可以不要了\n",
    "data.drop('EMI_Loan_Submitted',axis=1,inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Employer Name字段处理"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 看看个数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "57193"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(data['Employer_Name'].value_counts())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 不看也知道，每个人都有一个名字，太多了，懒癌晚期的同学直接drop掉了"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#丢掉\n",
    "data.drop('Employer_Name',axis=1,inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Existing_EMI字段"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x109a2c310>"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXEAAAEHCAYAAABY/HZ4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEA9JREFUeJzt3H2MZXV9x/H3B1ax9WHHh0QqCNOqhEbFKSmENLa9SCuL\nNoq1FpbGdKg2m1ZMaf8QTGxgExtLbdqJ2JasXdnaBCH1KVgRaehejPUBWl3EujysWoWVWq2ydhHt\ndv32jzkze5mdhzu7s3vPuft+JRvu75zfnPlBdj6c+ZyHVBWSpG46btQLkCQdOkNckjrMEJekDjPE\nJanDDHFJ6jBDXJI67KiHeJKtSb6V5ItDzP2LJF9I8vkk9yX57tFYoyR1RY72feJJXgrsBd5XVWes\n4usuA6aq6o1HbHGS1DFH/Uy8qj4FfG9wW5KfSfLxJHcluSPJaYt86Ubg/UdlkZLUEetGvYDGFmBT\nVX0lydnA3wDnze1McgowCfzzaJYnSe008hBP8mTgF4B/SJJm8xMWTLsY+ED5jgBJepyRhzizlc73\nqurMZeZcDPz+UVqPJHXGip34MHeTJHlXkgeS7EgyNcT3TfOHqvof4G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Jnta8u+cFzfiGJG9oPn8tyTOS/GRzlv2FJF9M8rok\nbwaeA2xPcvuC+acm+XKSLUm+lOTWJCc0c85KcndzVv1nSe5Z7ZoH3AK8svm8EXj/qv5rSCswxNU2\nP7GgmnhdVX2f2VtY/y7JRcBEVW1t5s+dyW4AdlfVz1XVGcCtVXUts88r9KrqvAXzAZ4PXFtVLwL2\nAK9ttr8X+N3mN4L9rHy2/IsL1vzTA9/rRmbfN3QCcAbwudX/J5GWZp2itvnBYnVKVd2e5DeBvwJe\nPLBr7iz4HuDPk7wD+FhVfWpgfxaZD/C1qpo7y/43YDLJeuApVXVns/0GDpxJL2WpOoWq+lKSSWbP\nwj/G8mft0qp5Jq5OyOzjkz/LbM/8zIX7q+oB4Exmw/ztSd42xGF/NPB5PwdOatY6aG8G3olVio4A\nQ1xts1SA/hHwZeAS4Pokxz/ui5KfAh6rqhuYDcy5s/nvA0vdjXLQ96qqPcD3k5zVbLr4MNY8t/29\nwOaq+vchjiWtinWK2uZJST7PbAAWcCuwDfgd4Kyq+kGSO4C3AZs50Fe/GHhnkh8D/wv8XrP9PcCt\nSXY3vfhgv71U1/1G4G+T7AfuYLYvX85LF6z57VX1obnjV9VuZt/JL605n9iUFkjy5Kp6tPl8BXBi\nVf3hiJclLcozcelgr0zyVmZ/Pv4DmB7paqRleCYuDSHJy4FrOFDBBPhqVb126a+SjjxDXJI6zLtT\nJKnDDHFJ6jBDXJI6zBCXpA4zxCWpw/4fn10SfexcgdUAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x108aa9750>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "data.boxplot(column='Existing_EMI',return_type='axes')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "count    1.246260e+05\n",
       "mean     3.636342e+03\n",
       "std      3.369124e+04\n",
       "min      0.000000e+00\n",
       "25%               NaN\n",
       "50%               NaN\n",
       "75%               NaN\n",
       "max      1.000000e+07\n",
       "Name: Existing_EMI, dtype: float64"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['Existing_EMI'].describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#缺省值不多，用均值代替\n",
    "data['Existing_EMI'].fillna(0, inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Interest_Rate字段:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x10a05f250>"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW0AAAEBCAYAAACzN/QDAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEJhJREFUeJzt3W+MZXV9x/H3h8VQKGVnq8LSQp1gWqJJdbTSP5KWaauV\nWgPUKG3kwY7yQNuoiNaKTZtdTWMUGxrbxCeizkhqFUlTQaMQYS6JEKnCrlAgPJE1Me2u/7CiNI2B\nbx/M2WWYndm5d3Zm7jn3vF/JZc7v3HPu/d5l+XLmc8753VQVkqRuOGncBUiShmfTlqQOsWlLUofY\ntCWpQ2zaktQhNm1J6pChm3aSk5Lcl+TmZrwryW1JHklya5KdW1emJAlGO9K+Cnho2fga4CtVdT5w\nB/DezSxMknSsoZp2knOAVwPXL1t9KbDQLC8Al21uaZKklYY90v5H4N3A8tsnz6qqwwBVdQg4c5Nr\nkyStsG7TTvInwOGqOgDkOJt6P7wkbbGTh9jmQuCSJK8GTgV+IckNwKEkZ1XV4SS7ge+utnMSm7kk\nbUBVHXOgnFEmjEpyEfCuqrokybXAD6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ZHPvAE4b5UWTjPr3egZ49RDbfaaqXgr8LrA3yXPX2X4WePmItUjHZdPW2DVH\npItJPpfk4SQ3NOvfBvwSsJjk9mbdHyW5O8k3knw2yWnN+keTfDDJN4DXJTkvyZeSfD3JnUl+rdnu\n9UkeSLI/ySDJs4D3A5c3R9GvX6/eqvoh8C1gunnN1yT5WpJ7mzl5npvkecBbgHc0r3thkuckuSnJ\nPc3Dhq7RVZUPH2N5AD9ufl7E0lQJZ7N0aendwMub574F7GqWnw3cCZzajP8a+Ntm+VHgr5a99leA\n5zfLvwnc3izfD5zdLJ/R/NwD/NM6tR7dBvgV4BDwi81457LtrgQ+3CzvBd657Ll/Wfa5zgUeGve/\nAx/de2z05hpps/1HVf03QJIDLB3F3s0z7xH4beCFwF1ZumPrWc02R3y22f/nWYolPpen7+x6VvPz\nLmAhyY3Av41Y458nuQg4H3h3LR1xA5zbvN7Zzfs8usb+rwBesKym05OcVlVPjFiHesymrbb4v2XL\nT7L6380At1XVFWu8xk+bnycBj9VS/vwMVfUXSS4AXgPcm+SYbY7jM1X19iS/AdyY5BNV9VPgn4F/\nqKovNk197xr7B/itqvrZCO8pPYOZtsZpmLtlfwyc0Sx/DbgwyfMBkpyW5FdX7lBVjwOPJnnd0TdK\nXtT8PK+qvl5Ve1mafuFc4PFl77GuqrqXpbuCr2pWnQH8V7O8Z9mmK1/3tmX7kOTFw76ndIRNW+O0\n1tUjy9d/DPhyktur6vvAG4F/TfJNlqKR89d4rSuAK5McSPKfwCXN+g8nub/5Uo+7q+p+YBF44bAn\nIhvXAm9pToS+D7gpydeB7y3b5hbgT4+ciATeDrwsyTebmt485HtJR3lHpCR1iEfaktQhnoiUlkky\nx1LuvPxX0Luq6m3jqUh6JuMRSeoQ4xFJ6hCbtiR1iE1bkjrEpi1JHWLTlqQO+X+2nl4VRBTAYgAA\nAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10a053d10>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "data.boxplot(column=['Interest_Rate'],return_type='axes')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   Interest_Rate  Interest_Rate_Missing\n",
      "0            NaN                      1\n",
      "1          13.25                      0\n",
      "2            NaN                      1\n",
      "3            NaN                      1\n",
      "4            NaN                      1\n",
      "5          13.99                      0\n",
      "6            NaN                      1\n",
      "7            NaN                      1\n",
      "8          14.85                      0\n",
      "9          18.25                      0\n"
     ]
    }
   ],
   "source": [
    "#缺省值太多，也造一个字段，表示有无\n",
    "data['Interest_Rate_Missing'] = data['Interest_Rate'].apply(lambda x: 1 if pd.isnull(x) else 0)\n",
    "print data[['Interest_Rate','Interest_Rate_Missing']].head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "data.drop('Interest_Rate',axis=1,inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Lead Creation Date字段"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Device_Type</th>\n",
       "      <th>Disbursed</th>\n",
       "      <th>Existing_EMI</th>\n",
       "      <th>Filled_Form</th>\n",
       "      <th>Gender</th>\n",
       "      <th>ID</th>\n",
       "      <th>Loan_Amount_Applied</th>\n",
       "      <th>Loan_Amount_Submitted</th>\n",
       "      <th>Loan_Tenure_Applied</th>\n",
       "      <th>Loan_Tenure_Submitted</th>\n",
       "      <th>...</th>\n",
       "      <th>Salary_Account</th>\n",
       "      <th>Source</th>\n",
       "      <th>Var1</th>\n",
       "      <th>Var2</th>\n",
       "      <th>Var4</th>\n",
       "      <th>Var5</th>\n",
       "      <th>source</th>\n",
       "      <th>Age</th>\n",
       "      <th>EMI_Loan_Submitted_Missing</th>\n",
       "      <th>Interest_Rate_Missing</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Female</td>\n",
       "      <td>ID000002C20</td>\n",
       "      <td>300000.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>5.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>HDFC Bank</td>\n",
       "      <td>S122</td>\n",
       "      <td>HBXX</td>\n",
       "      <td>G</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>train</td>\n",
       "      <td>37</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>ID000004E40</td>\n",
       "      <td>200000.0</td>\n",
       "      <td>200000.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>...</td>\n",
       "      <td>ICICI Bank</td>\n",
       "      <td>S122</td>\n",
       "      <td>HBXA</td>\n",
       "      <td>G</td>\n",
       "      <td>3</td>\n",
       "      <td>13</td>\n",
       "      <td>train</td>\n",
       "      <td>30</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>ID000007H20</td>\n",
       "      <td>600000.0</td>\n",
       "      <td>450000.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>...</td>\n",
       "      <td>State Bank of India</td>\n",
       "      <td>S143</td>\n",
       "      <td>HBXX</td>\n",
       "      <td>B</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>train</td>\n",
       "      <td>34</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>ID000008I30</td>\n",
       "      <td>1000000.0</td>\n",
       "      <td>920000.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>State Bank of India</td>\n",
       "      <td>S143</td>\n",
       "      <td>HBXX</td>\n",
       "      <td>B</td>\n",
       "      <td>3</td>\n",
       "      <td>10</td>\n",
       "      <td>train</td>\n",
       "      <td>28</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>25000.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>ID000009J40</td>\n",
       "      <td>500000.0</td>\n",
       "      <td>500000.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>...</td>\n",
       "      <td>HDFC Bank</td>\n",
       "      <td>S134</td>\n",
       "      <td>HBXX</td>\n",
       "      <td>B</td>\n",
       "      <td>3</td>\n",
       "      <td>17</td>\n",
       "      <td>train</td>\n",
       "      <td>31</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 24 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   Device_Type  Disbursed  Existing_EMI Filled_Form  Gender           ID  \\\n",
       "0  Web-browser        0.0           0.0           N  Female  ID000002C20   \n",
       "1  Web-browser        0.0           0.0           N    Male  ID000004E40   \n",
       "2  Web-browser        0.0           0.0           N    Male  ID000007H20   \n",
       "3  Web-browser        0.0           0.0           N    Male  ID000008I30   \n",
       "4  Web-browser        0.0       25000.0           N    Male  ID000009J40   \n",
       "\n",
       "   Loan_Amount_Applied  Loan_Amount_Submitted  Loan_Tenure_Applied  \\\n",
       "0             300000.0                    NaN                  5.0   \n",
       "1             200000.0               200000.0                  2.0   \n",
       "2             600000.0               450000.0                  4.0   \n",
       "3            1000000.0               920000.0                  5.0   \n",
       "4             500000.0               500000.0                  2.0   \n",
       "\n",
       "   Loan_Tenure_Submitted          ...                 Salary_Account Source  \\\n",
       "0                    NaN          ...                      HDFC Bank   S122   \n",
       "1                    2.0          ...                     ICICI Bank   S122   \n",
       "2                    4.0          ...            State Bank of India   S143   \n",
       "3                    5.0          ...            State Bank of India   S143   \n",
       "4                    2.0          ...                      HDFC Bank   S134   \n",
       "\n",
       "   Var1  Var2 Var4 Var5 source Age  EMI_Loan_Submitted_Missing  \\\n",
       "0  HBXX     G    1    0  train  37                           1   \n",
       "1  HBXA     G    3   13  train  30                           0   \n",
       "2  HBXX     B    1    0  train  34                           1   \n",
       "3  HBXX     B    3   10  train  28                           1   \n",
       "4  HBXX     B    3   17  train  31                           1   \n",
       "\n",
       "   Interest_Rate_Missing  \n",
       "0                      1  \n",
       "1                      0  \n",
       "2                      1  \n",
       "3                      1  \n",
       "4                      1  \n",
       "\n",
       "[5 rows x 24 columns]"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#不！要！了！，是的，不要了！！！\n",
    "data.drop('Lead_Creation_Date',axis=1,inplace=True)\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Loan Amount and Tenure applied字段"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#找中位数去填补缺省值（因为缺省的不多）\n",
    "data['Loan_Amount_Applied'].fillna(data['Loan_Amount_Applied'].median(),inplace=True)\n",
    "data['Loan_Tenure_Applied'].fillna(data['Loan_Tenure_Applied'].median(),inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Device_Type</th>\n",
       "      <th>Disbursed</th>\n",
       "      <th>Existing_EMI</th>\n",
       "      <th>Filled_Form</th>\n",
       "      <th>Gender</th>\n",
       "      <th>ID</th>\n",
       "      <th>Loan_Amount_Applied</th>\n",
       "      <th>Loan_Amount_Submitted</th>\n",
       "      <th>Loan_Tenure_Applied</th>\n",
       "      <th>Loan_Tenure_Submitted</th>\n",
       "      <th>...</th>\n",
       "      <th>Salary_Account</th>\n",
       "      <th>Source</th>\n",
       "      <th>Var1</th>\n",
       "      <th>Var2</th>\n",
       "      <th>Var4</th>\n",
       "      <th>Var5</th>\n",
       "      <th>source</th>\n",
       "      <th>Age</th>\n",
       "      <th>EMI_Loan_Submitted_Missing</th>\n",
       "      <th>Interest_Rate_Missing</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Female</td>\n",
       "      <td>ID000002C20</td>\n",
       "      <td>300000.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>5.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>HDFC Bank</td>\n",
       "      <td>S122</td>\n",
       "      <td>HBXX</td>\n",
       "      <td>G</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>train</td>\n",
       "      <td>37</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>ID000004E40</td>\n",
       "      <td>200000.0</td>\n",
       "      <td>200000.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>...</td>\n",
       "      <td>ICICI Bank</td>\n",
       "      <td>S122</td>\n",
       "      <td>HBXA</td>\n",
       "      <td>G</td>\n",
       "      <td>3</td>\n",
       "      <td>13</td>\n",
       "      <td>train</td>\n",
       "      <td>30</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>ID000007H20</td>\n",
       "      <td>600000.0</td>\n",
       "      <td>450000.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>...</td>\n",
       "      <td>State Bank of India</td>\n",
       "      <td>S143</td>\n",
       "      <td>HBXX</td>\n",
       "      <td>B</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>train</td>\n",
       "      <td>34</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>ID000008I30</td>\n",
       "      <td>1000000.0</td>\n",
       "      <td>920000.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>State Bank of India</td>\n",
       "      <td>S143</td>\n",
       "      <td>HBXX</td>\n",
       "      <td>B</td>\n",
       "      <td>3</td>\n",
       "      <td>10</td>\n",
       "      <td>train</td>\n",
       "      <td>28</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>25000.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>ID000009J40</td>\n",
       "      <td>500000.0</td>\n",
       "      <td>500000.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>...</td>\n",
       "      <td>HDFC Bank</td>\n",
       "      <td>S134</td>\n",
       "      <td>HBXX</td>\n",
       "      <td>B</td>\n",
       "      <td>3</td>\n",
       "      <td>17</td>\n",
       "      <td>train</td>\n",
       "      <td>31</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 24 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   Device_Type  Disbursed  Existing_EMI Filled_Form  Gender           ID  \\\n",
       "0  Web-browser        0.0           0.0           N  Female  ID000002C20   \n",
       "1  Web-browser        0.0           0.0           N    Male  ID000004E40   \n",
       "2  Web-browser        0.0           0.0           N    Male  ID000007H20   \n",
       "3  Web-browser        0.0           0.0           N    Male  ID000008I30   \n",
       "4  Web-browser        0.0       25000.0           N    Male  ID000009J40   \n",
       "\n",
       "   Loan_Amount_Applied  Loan_Amount_Submitted  Loan_Tenure_Applied  \\\n",
       "0             300000.0                    NaN                  5.0   \n",
       "1             200000.0               200000.0                  2.0   \n",
       "2             600000.0               450000.0                  4.0   \n",
       "3            1000000.0               920000.0                  5.0   \n",
       "4             500000.0               500000.0                  2.0   \n",
       "\n",
       "   Loan_Tenure_Submitted          ...                 Salary_Account Source  \\\n",
       "0                    NaN          ...                      HDFC Bank   S122   \n",
       "1                    2.0          ...                     ICICI Bank   S122   \n",
       "2                    4.0          ...            State Bank of India   S143   \n",
       "3                    5.0          ...            State Bank of India   S143   \n",
       "4                    2.0          ...                      HDFC Bank   S134   \n",
       "\n",
       "   Var1  Var2 Var4 Var5 source Age  EMI_Loan_Submitted_Missing  \\\n",
       "0  HBXX     G    1    0  train  37                           1   \n",
       "1  HBXA     G    3   13  train  30                           0   \n",
       "2  HBXX     B    1    0  train  34                           1   \n",
       "3  HBXX     B    3   10  train  28                           1   \n",
       "4  HBXX     B    3   17  train  31                           1   \n",
       "\n",
       "   Interest_Rate_Missing  \n",
       "0                      1  \n",
       "1                      0  \n",
       "2                      1  \n",
       "3                      1  \n",
       "4                      1  \n",
       "\n",
       "[5 rows x 24 columns]"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Loan Amount and Tenure selected"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 缺省值太多。。。是否缺省。。。\n",
    "data['Loan_Amount_Submitted_Missing'] = data['Loan_Amount_Submitted'].apply(lambda x: 1 if pd.isnull(x) else 0)\n",
    "data['Loan_Tenure_Submitted_Missing'] = data['Loan_Tenure_Submitted'].apply(lambda x: 1 if pd.isnull(x) else 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Device_Type</th>\n",
       "      <th>Disbursed</th>\n",
       "      <th>Employer_Name</th>\n",
       "      <th>Existing_EMI</th>\n",
       "      <th>Filled_Form</th>\n",
       "      <th>Gender</th>\n",
       "      <th>ID</th>\n",
       "      <th>Loan_Amount_Applied</th>\n",
       "      <th>Loan_Amount_Submitted</th>\n",
       "      <th>Loan_Tenure_Applied</th>\n",
       "      <th>...</th>\n",
       "      <th>Var1</th>\n",
       "      <th>Var2</th>\n",
       "      <th>Var4</th>\n",
       "      <th>Var5</th>\n",
       "      <th>source</th>\n",
       "      <th>Age</th>\n",
       "      <th>EMI_Loan_Submitted_Missing</th>\n",
       "      <th>Interest_Rate_Missing</th>\n",
       "      <th>Loan_Amount_Submitted_Missing</th>\n",
       "      <th>Loan_Tenure_Submitted_Missing</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>CYBOSOL</td>\n",
       "      <td>0.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Female</td>\n",
       "      <td>ID000002C20</td>\n",
       "      <td>300000.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>HBXX</td>\n",
       "      <td>G</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>train</td>\n",
       "      <td>37</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>TATA CONSULTANCY SERVICES LTD (TCS)</td>\n",
       "      <td>0.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>ID000004E40</td>\n",
       "      <td>200000.0</td>\n",
       "      <td>200000.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>...</td>\n",
       "      <td>HBXA</td>\n",
       "      <td>G</td>\n",
       "      <td>3</td>\n",
       "      <td>13</td>\n",
       "      <td>train</td>\n",
       "      <td>30</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>ALCHEMIST HOSPITALS LTD</td>\n",
       "      <td>0.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>ID000007H20</td>\n",
       "      <td>600000.0</td>\n",
       "      <td>450000.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>...</td>\n",
       "      <td>HBXX</td>\n",
       "      <td>B</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>train</td>\n",
       "      <td>34</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>BIHAR GOVERNMENT</td>\n",
       "      <td>0.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>ID000008I30</td>\n",
       "      <td>1000000.0</td>\n",
       "      <td>920000.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>HBXX</td>\n",
       "      <td>B</td>\n",
       "      <td>3</td>\n",
       "      <td>10</td>\n",
       "      <td>train</td>\n",
       "      <td>28</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>GLOBAL EDGE SOFTWARE</td>\n",
       "      <td>25000.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>ID000009J40</td>\n",
       "      <td>500000.0</td>\n",
       "      <td>500000.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>...</td>\n",
       "      <td>HBXX</td>\n",
       "      <td>B</td>\n",
       "      <td>3</td>\n",
       "      <td>17</td>\n",
       "      <td>train</td>\n",
       "      <td>31</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 27 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   Device_Type  Disbursed                        Employer_Name  Existing_EMI  \\\n",
       "0  Web-browser        0.0                              CYBOSOL           0.0   \n",
       "1  Web-browser        0.0  TATA CONSULTANCY SERVICES LTD (TCS)           0.0   \n",
       "2  Web-browser        0.0              ALCHEMIST HOSPITALS LTD           0.0   \n",
       "3  Web-browser        0.0                     BIHAR GOVERNMENT           0.0   \n",
       "4  Web-browser        0.0                 GLOBAL EDGE SOFTWARE       25000.0   \n",
       "\n",
       "  Filled_Form  Gender           ID  Loan_Amount_Applied  \\\n",
       "0           N  Female  ID000002C20             300000.0   \n",
       "1           N    Male  ID000004E40             200000.0   \n",
       "2           N    Male  ID000007H20             600000.0   \n",
       "3           N    Male  ID000008I30            1000000.0   \n",
       "4           N    Male  ID000009J40             500000.0   \n",
       "\n",
       "   Loan_Amount_Submitted  Loan_Tenure_Applied              ...                \\\n",
       "0                    NaN                  5.0              ...                 \n",
       "1               200000.0                  2.0              ...                 \n",
       "2               450000.0                  4.0              ...                 \n",
       "3               920000.0                  5.0              ...                 \n",
       "4               500000.0                  2.0              ...                 \n",
       "\n",
       "   Var1  Var2 Var4  Var5  source Age EMI_Loan_Submitted_Missing  \\\n",
       "0  HBXX     G    1     0   train  37                          1   \n",
       "1  HBXA     G    3    13   train  30                          0   \n",
       "2  HBXX     B    1     0   train  34                          1   \n",
       "3  HBXX     B    3    10   train  28                          1   \n",
       "4  HBXX     B    3    17   train  31                          1   \n",
       "\n",
       "  Interest_Rate_Missing Loan_Amount_Submitted_Missing  \\\n",
       "0                     1                             1   \n",
       "1                     0                             0   \n",
       "2                     1                             0   \n",
       "3                     1                             0   \n",
       "4                     1                             0   \n",
       "\n",
       "   Loan_Tenure_Submitted_Missing  \n",
       "0                              1  \n",
       "1                              0  \n",
       "2                              0  \n",
       "3                              0  \n",
       "4                              0  \n",
       "\n",
       "[5 rows x 27 columns]"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#原来的字段就没用了\n",
    "data.drop(['Loan_Amount_Submitted','Loan_Tenure_Submitted'],axis=1,inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### LoggedIn"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#没想好怎么用。。。不要了。。。\n",
    "data.drop('LoggedIn',axis=1,inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### salary account"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 可能对接多个银行，所以也不要了\n",
    "data.drop('Salary_Account',axis=1,inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Processing_Fee"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#和之前一样的处理，有或者没有\n",
    "data['Processing_Fee_Missing'] = data['Processing_Fee'].apply(lambda x: 1 if pd.isnull(x) else 0)\n",
    "#旧的字段不要了\n",
    "data.drop('Processing_Fee',axis=1,inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Source"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "S122      55249\n",
       "S133      42900\n",
       "others    26588\n",
       "Name: Source, dtype: int64"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['Source'] = data['Source'].apply(lambda x: 'others' if x not in ['S122','S133'] else x)\n",
    "data['Source'].value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 最终的数据样式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Device_Type</th>\n",
       "      <th>Disbursed</th>\n",
       "      <th>Existing_EMI</th>\n",
       "      <th>Filled_Form</th>\n",
       "      <th>Gender</th>\n",
       "      <th>ID</th>\n",
       "      <th>Loan_Amount_Applied</th>\n",
       "      <th>Loan_Tenure_Applied</th>\n",
       "      <th>Mobile_Verified</th>\n",
       "      <th>Monthly_Income</th>\n",
       "      <th>...</th>\n",
       "      <th>Var2</th>\n",
       "      <th>Var4</th>\n",
       "      <th>Var5</th>\n",
       "      <th>source</th>\n",
       "      <th>Age</th>\n",
       "      <th>EMI_Loan_Submitted_Missing</th>\n",
       "      <th>Interest_Rate_Missing</th>\n",
       "      <th>Loan_Amount_Submitted_Missing</th>\n",
       "      <th>Loan_Tenure_Submitted_Missing</th>\n",
       "      <th>Processing_Fee_Missing</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Female</td>\n",
       "      <td>ID000002C20</td>\n",
       "      <td>300000.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>N</td>\n",
       "      <td>20000</td>\n",
       "      <td>...</td>\n",
       "      <td>G</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>train</td>\n",
       "      <td>37</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>ID000004E40</td>\n",
       "      <td>200000.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Y</td>\n",
       "      <td>35000</td>\n",
       "      <td>...</td>\n",
       "      <td>G</td>\n",
       "      <td>3</td>\n",
       "      <td>13</td>\n",
       "      <td>train</td>\n",
       "      <td>30</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>ID000007H20</td>\n",
       "      <td>600000.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>Y</td>\n",
       "      <td>22500</td>\n",
       "      <td>...</td>\n",
       "      <td>B</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>train</td>\n",
       "      <td>34</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>ID000008I30</td>\n",
       "      <td>1000000.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>Y</td>\n",
       "      <td>35000</td>\n",
       "      <td>...</td>\n",
       "      <td>B</td>\n",
       "      <td>3</td>\n",
       "      <td>10</td>\n",
       "      <td>train</td>\n",
       "      <td>28</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Web-browser</td>\n",
       "      <td>0.0</td>\n",
       "      <td>25000.0</td>\n",
       "      <td>N</td>\n",
       "      <td>Male</td>\n",
       "      <td>ID000009J40</td>\n",
       "      <td>500000.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Y</td>\n",
       "      <td>100000</td>\n",
       "      <td>...</td>\n",
       "      <td>B</td>\n",
       "      <td>3</td>\n",
       "      <td>17</td>\n",
       "      <td>train</td>\n",
       "      <td>31</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 22 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   Device_Type  Disbursed  Existing_EMI Filled_Form  Gender           ID  \\\n",
       "0  Web-browser        0.0           0.0           N  Female  ID000002C20   \n",
       "1  Web-browser        0.0           0.0           N    Male  ID000004E40   \n",
       "2  Web-browser        0.0           0.0           N    Male  ID000007H20   \n",
       "3  Web-browser        0.0           0.0           N    Male  ID000008I30   \n",
       "4  Web-browser        0.0       25000.0           N    Male  ID000009J40   \n",
       "\n",
       "   Loan_Amount_Applied  Loan_Tenure_Applied Mobile_Verified  Monthly_Income  \\\n",
       "0             300000.0                  5.0               N           20000   \n",
       "1             200000.0                  2.0               Y           35000   \n",
       "2             600000.0                  4.0               Y           22500   \n",
       "3            1000000.0                  5.0               Y           35000   \n",
       "4             500000.0                  2.0               Y          100000   \n",
       "\n",
       "            ...           Var2 Var4 Var5  source  Age  \\\n",
       "0           ...              G    1    0   train   37   \n",
       "1           ...              G    3   13   train   30   \n",
       "2           ...              B    1    0   train   34   \n",
       "3           ...              B    3   10   train   28   \n",
       "4           ...              B    3   17   train   31   \n",
       "\n",
       "  EMI_Loan_Submitted_Missing  Interest_Rate_Missing  \\\n",
       "0                          1                      1   \n",
       "1                          0                      0   \n",
       "2                          1                      1   \n",
       "3                          1                      1   \n",
       "4                          1                      1   \n",
       "\n",
       "   Loan_Amount_Submitted_Missing  Loan_Tenure_Submitted_Missing  \\\n",
       "0                              1                              1   \n",
       "1                              0                              0   \n",
       "2                              0                              0   \n",
       "3                              0                              0   \n",
       "4                              0                              0   \n",
       "\n",
       "   Processing_Fee_Missing  \n",
       "0                       1  \n",
       "1                       1  \n",
       "2                       1  \n",
       "3                       1  \n",
       "4                       1  \n",
       "\n",
       "[5 rows x 22 columns]"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Disbursed</th>\n",
       "      <th>Existing_EMI</th>\n",
       "      <th>Loan_Amount_Applied</th>\n",
       "      <th>Loan_Tenure_Applied</th>\n",
       "      <th>Monthly_Income</th>\n",
       "      <th>Var4</th>\n",
       "      <th>Var5</th>\n",
       "      <th>Age</th>\n",
       "      <th>EMI_Loan_Submitted_Missing</th>\n",
       "      <th>Interest_Rate_Missing</th>\n",
       "      <th>Loan_Amount_Submitted_Missing</th>\n",
       "      <th>Loan_Tenure_Submitted_Missing</th>\n",
       "      <th>Processing_Fee_Missing</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>87020.000000</td>\n",
       "      <td>1.247370e+05</td>\n",
       "      <td>1.247370e+05</td>\n",
       "      <td>124737.000000</td>\n",
       "      <td>1.247370e+05</td>\n",
       "      <td>124737.000000</td>\n",
       "      <td>124737.000000</td>\n",
       "      <td>124737.000000</td>\n",
       "      <td>124737.000000</td>\n",
       "      <td>124737.000000</td>\n",
       "      <td>124737.000000</td>\n",
       "      <td>124737.000000</td>\n",
       "      <td>124737.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>0.014629</td>\n",
       "      <td>3.633107e+03</td>\n",
       "      <td>2.298744e+05</td>\n",
       "      <td>2.138075</td>\n",
       "      <td>5.309073e+04</td>\n",
       "      <td>2.950560</td>\n",
       "      <td>4.964774</td>\n",
       "      <td>30.906996</td>\n",
       "      <td>0.680640</td>\n",
       "      <td>0.680640</td>\n",
       "      <td>0.397116</td>\n",
       "      <td>0.397116</td>\n",
       "      <td>0.684208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.120062</td>\n",
       "      <td>3.367642e+04</td>\n",
       "      <td>3.539938e+05</td>\n",
       "      <td>2.014874</td>\n",
       "      <td>1.823394e+06</td>\n",
       "      <td>1.695261</td>\n",
       "      <td>5.669784</td>\n",
       "      <td>7.137860</td>\n",
       "      <td>0.466231</td>\n",
       "      <td>0.466231</td>\n",
       "      <td>0.489302</td>\n",
       "      <td>0.489302</td>\n",
       "      <td>0.464833</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>18.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.650000e+04</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>26.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>1.000000e+05</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>2.500000e+04</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>29.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>NaN</td>\n",
       "      <td>3.500000e+03</td>\n",
       "      <td>3.000000e+05</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>4.000000e+04</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>11.000000</td>\n",
       "      <td>34.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000e+07</td>\n",
       "      <td>1.500000e+07</td>\n",
       "      <td>10.000000</td>\n",
       "      <td>4.445544e+08</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>18.000000</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          Disbursed  Existing_EMI  Loan_Amount_Applied  Loan_Tenure_Applied  \\\n",
       "count  87020.000000  1.247370e+05         1.247370e+05        124737.000000   \n",
       "mean       0.014629  3.633107e+03         2.298744e+05             2.138075   \n",
       "std        0.120062  3.367642e+04         3.539938e+05             2.014874   \n",
       "min        0.000000  0.000000e+00         0.000000e+00             0.000000   \n",
       "25%             NaN  0.000000e+00         0.000000e+00             0.000000   \n",
       "50%             NaN  0.000000e+00         1.000000e+05             2.000000   \n",
       "75%             NaN  3.500000e+03         3.000000e+05             4.000000   \n",
       "max        1.000000  1.000000e+07         1.500000e+07            10.000000   \n",
       "\n",
       "       Monthly_Income           Var4           Var5            Age  \\\n",
       "count    1.247370e+05  124737.000000  124737.000000  124737.000000   \n",
       "mean     5.309073e+04       2.950560       4.964774      30.906996   \n",
       "std      1.823394e+06       1.695261       5.669784       7.137860   \n",
       "min      0.000000e+00       0.000000       0.000000      18.000000   \n",
       "25%      1.650000e+04       1.000000       0.000000      26.000000   \n",
       "50%      2.500000e+04       3.000000       2.000000      29.000000   \n",
       "75%      4.000000e+04       5.000000      11.000000      34.000000   \n",
       "max      4.445544e+08       7.000000      18.000000     100.000000   \n",
       "\n",
       "       EMI_Loan_Submitted_Missing  Interest_Rate_Missing  \\\n",
       "count               124737.000000          124737.000000   \n",
       "mean                     0.680640               0.680640   \n",
       "std                      0.466231               0.466231   \n",
       "min                      0.000000               0.000000   \n",
       "25%                      0.000000               0.000000   \n",
       "50%                      1.000000               1.000000   \n",
       "75%                      1.000000               1.000000   \n",
       "max                      1.000000               1.000000   \n",
       "\n",
       "       Loan_Amount_Submitted_Missing  Loan_Tenure_Submitted_Missing  \\\n",
       "count                  124737.000000                  124737.000000   \n",
       "mean                        0.397116                       0.397116   \n",
       "std                         0.489302                       0.489302   \n",
       "min                         0.000000                       0.000000   \n",
       "25%                         0.000000                       0.000000   \n",
       "50%                         0.000000                       0.000000   \n",
       "75%                         1.000000                       1.000000   \n",
       "max                         1.000000                       1.000000   \n",
       "\n",
       "       Processing_Fee_Missing  \n",
       "count           124737.000000  \n",
       "mean                 0.684208  \n",
       "std                  0.464833  \n",
       "min                  0.000000  \n",
       "25%                  0.000000  \n",
       "50%                  1.000000  \n",
       "75%                  1.000000  \n",
       "max                  1.000000  "
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Device_Type                          0\n",
       "Disbursed                        37717\n",
       "Existing_EMI                         0\n",
       "Filled_Form                          0\n",
       "Gender                               0\n",
       "ID                                   0\n",
       "Loan_Amount_Applied                  0\n",
       "Loan_Tenure_Applied                  0\n",
       "Mobile_Verified                      0\n",
       "Monthly_Income                       0\n",
       "Source                               0\n",
       "Var1                                 0\n",
       "Var2                                 0\n",
       "Var4                                 0\n",
       "Var5                                 0\n",
       "source                               0\n",
       "Age                                  0\n",
       "EMI_Loan_Submitted_Missing           0\n",
       "Interest_Rate_Missing                0\n",
       "Loan_Amount_Submitted_Missing        0\n",
       "Loan_Tenure_Submitted_Missing        0\n",
       "Processing_Fee_Missing               0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.apply(lambda x: sum(x.isnull()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Device_Type                       object\n",
       "Disbursed                        float64\n",
       "Existing_EMI                     float64\n",
       "Filled_Form                       object\n",
       "Gender                            object\n",
       "ID                                object\n",
       "Loan_Amount_Applied              float64\n",
       "Loan_Tenure_Applied              float64\n",
       "Mobile_Verified                   object\n",
       "Monthly_Income                     int64\n",
       "Source                            object\n",
       "Var1                              object\n",
       "Var2                              object\n",
       "Var4                               int64\n",
       "Var5                               int64\n",
       "source                            object\n",
       "Age                                int64\n",
       "EMI_Loan_Submitted_Missing         int64\n",
       "Interest_Rate_Missing              int64\n",
       "Loan_Amount_Submitted_Missing      int64\n",
       "Loan_Tenure_Submitted_Missing      int64\n",
       "Processing_Fee_Missing             int64\n",
       "dtype: object"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.dtypes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 数值编码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import LabelEncoder\n",
    "le = LabelEncoder()\n",
    "var_to_encode = ['Device_Type','Filled_Form','Gender','Var1','Var2','Mobile_Verified','Source']\n",
    "for col in var_to_encode:\n",
    "    data[col] = le.fit_transform(data[col])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Device_Type</th>\n",
       "      <th>Disbursed</th>\n",
       "      <th>Existing_EMI</th>\n",
       "      <th>Filled_Form</th>\n",
       "      <th>Gender</th>\n",
       "      <th>ID</th>\n",
       "      <th>Loan_Amount_Applied</th>\n",
       "      <th>Loan_Tenure_Applied</th>\n",
       "      <th>Mobile_Verified</th>\n",
       "      <th>Monthly_Income</th>\n",
       "      <th>...</th>\n",
       "      <th>Var2</th>\n",
       "      <th>Var4</th>\n",
       "      <th>Var5</th>\n",
       "      <th>source</th>\n",
       "      <th>Age</th>\n",
       "      <th>EMI_Loan_Submitted_Missing</th>\n",
       "      <th>Interest_Rate_Missing</th>\n",
       "      <th>Loan_Amount_Submitted_Missing</th>\n",
       "      <th>Loan_Tenure_Submitted_Missing</th>\n",
       "      <th>Processing_Fee_Missing</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>ID000002C20</td>\n",
       "      <td>300000.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>0</td>\n",
       "      <td>20000</td>\n",
       "      <td>...</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>train</td>\n",
       "      <td>37</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>ID000004E40</td>\n",
       "      <td>200000.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1</td>\n",
       "      <td>35000</td>\n",
       "      <td>...</td>\n",
       "      <td>6</td>\n",
       "      <td>3</td>\n",
       "      <td>13</td>\n",
       "      <td>train</td>\n",
       "      <td>30</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>ID000007H20</td>\n",
       "      <td>600000.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1</td>\n",
       "      <td>22500</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>train</td>\n",
       "      <td>34</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>ID000008I30</td>\n",
       "      <td>1000000.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1</td>\n",
       "      <td>35000</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>10</td>\n",
       "      <td>train</td>\n",
       "      <td>28</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>25000.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>ID000009J40</td>\n",
       "      <td>500000.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1</td>\n",
       "      <td>100000</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>17</td>\n",
       "      <td>train</td>\n",
       "      <td>31</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 22 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   Device_Type  Disbursed  Existing_EMI  Filled_Form  Gender           ID  \\\n",
       "0            1        0.0           0.0            0       0  ID000002C20   \n",
       "1            1        0.0           0.0            0       1  ID000004E40   \n",
       "2            1        0.0           0.0            0       1  ID000007H20   \n",
       "3            1        0.0           0.0            0       1  ID000008I30   \n",
       "4            1        0.0       25000.0            0       1  ID000009J40   \n",
       "\n",
       "   Loan_Amount_Applied  Loan_Tenure_Applied  Mobile_Verified  Monthly_Income  \\\n",
       "0             300000.0                  5.0                0           20000   \n",
       "1             200000.0                  2.0                1           35000   \n",
       "2             600000.0                  4.0                1           22500   \n",
       "3            1000000.0                  5.0                1           35000   \n",
       "4             500000.0                  2.0                1          100000   \n",
       "\n",
       "            ...            Var2  Var4  Var5  source  Age  \\\n",
       "0           ...               6     1     0   train   37   \n",
       "1           ...               6     3    13   train   30   \n",
       "2           ...               1     1     0   train   34   \n",
       "3           ...               1     3    10   train   28   \n",
       "4           ...               1     3    17   train   31   \n",
       "\n",
       "  EMI_Loan_Submitted_Missing  Interest_Rate_Missing  \\\n",
       "0                          1                      1   \n",
       "1                          0                      0   \n",
       "2                          1                      1   \n",
       "3                          1                      1   \n",
       "4                          1                      1   \n",
       "\n",
       "   Loan_Amount_Submitted_Missing  Loan_Tenure_Submitted_Missing  \\\n",
       "0                              1                              1   \n",
       "1                              0                              0   \n",
       "2                              0                              0   \n",
       "3                              0                              0   \n",
       "4                              0                              0   \n",
       "\n",
       "   Processing_Fee_Missing  \n",
       "0                       1  \n",
       "1                       1  \n",
       "2                       1  \n",
       "3                       1  \n",
       "4                       1  \n",
       "\n",
       "[5 rows x 22 columns]"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Device_Type                        int64\n",
       "Disbursed                        float64\n",
       "Existing_EMI                     float64\n",
       "Filled_Form                        int64\n",
       "Gender                             int64\n",
       "ID                                object\n",
       "Loan_Amount_Applied              float64\n",
       "Loan_Tenure_Applied              float64\n",
       "Mobile_Verified                    int64\n",
       "Monthly_Income                     int64\n",
       "Source                             int64\n",
       "Var1                               int64\n",
       "Var2                               int64\n",
       "Var4                               int64\n",
       "Var5                               int64\n",
       "source                            object\n",
       "Age                                int64\n",
       "EMI_Loan_Submitted_Missing         int64\n",
       "Interest_Rate_Missing              int64\n",
       "Loan_Amount_Submitted_Missing      int64\n",
       "Loan_Tenure_Submitted_Missing      int64\n",
       "Processing_Fee_Missing             int64\n",
       "dtype: object"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.dtypes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 类别型的One-Hot 编码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index([u'Disbursed', u'Existing_EMI', u'ID', u'Loan_Amount_Applied',\n",
       "       u'Loan_Tenure_Applied', u'Monthly_Income', u'Var4', u'Var5', u'source',\n",
       "       u'Age', u'EMI_Loan_Submitted_Missing', u'Interest_Rate_Missing',\n",
       "       u'Loan_Amount_Submitted_Missing', u'Loan_Tenure_Submitted_Missing',\n",
       "       u'Processing_Fee_Missing', u'Device_Type_0', u'Device_Type_1',\n",
       "       u'Filled_Form_0', u'Filled_Form_1', u'Gender_0', u'Gender_1', u'Var1_0',\n",
       "       u'Var1_1', u'Var1_2', u'Var1_3', u'Var1_4', u'Var1_5', u'Var1_6',\n",
       "       u'Var1_7', u'Var1_8', u'Var1_9', u'Var1_10', u'Var1_11', u'Var1_12',\n",
       "       u'Var1_13', u'Var1_14', u'Var1_15', u'Var1_16', u'Var1_17', u'Var1_18',\n",
       "       u'Var2_0', u'Var2_1', u'Var2_2', u'Var2_3', u'Var2_4', u'Var2_5',\n",
       "       u'Var2_6', u'Mobile_Verified_0', u'Mobile_Verified_1', u'Source_0',\n",
       "       u'Source_1', u'Source_2'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pd.get_dummies(data, columns=var_to_encode)\n",
    "data.columns"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 区分训练和测试数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "train = data.loc[data['source']=='train']\n",
    "test = data.loc[data['source']=='test']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Library/Python/2.7/site-packages/ipykernel/__main__.py:1: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "  if __name__ == '__main__':\n",
      "/Library/Python/2.7/site-packages/ipykernel/__main__.py:2: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "  from ipykernel import kernelapp as app\n"
     ]
    }
   ],
   "source": [
    "train.drop('source',axis=1,inplace=True)\n",
    "test.drop(['source','Disbursed'],axis=1,inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "train.to_csv('train_modified.csv',index=False)\n",
    "test.to_csv('test_modified.csv',index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
